<{extends file="layout.tpl"}>

<{block name=css}>
<style type="text/css">
.m-userDetail-box li:after{ content: ''; display: block; clear: both; }
.m-userDetail-box li{ line-height: 34px; margin: 10px 0; }
.m-userDetail-box li:last-child{ text-align: center; margin-top: 30px; }
.m-userDetail-box .form-control{ width: 260px; }
.m-userDetail-title{ 
	background: #2580A2; 
	color: #fff; 
	font-size: 14px;
	padding-left: 8px;
}
</style>
<{/block}>

<{block name=content}>
<section class="m-panel-box">
	<h4>用户权限管理</h4>
	<div class="m-panel-body">
		<ul class="m-userDetail-box">
			<li class="m-userDetail-title">用户权限</li>
			<li>
				<div class="col-md-4">disabled</div>
				<div class="col-md-8"><input type="checkbox" name="disabled">启用禁用的权限将阻止用户登录。</div>
			</li>
			<li>
				<div class="col-md-4">管理</div>
				<div class="col-md-8"><input type="checkbox" name="admin">允许配置用户帐号</div>
			</li>
			<li>
				<div class="col-md-4">namedadmins</div>
				<div class="col-md-8"><input type="checkbox" name="namedadmins"/>完整管理域，记录和应用程序的默认值</div>
			</li>
			<li>
				<span class="btn btn-md btn-primary savePri">保存设置</span>
			</li>
		</ul>
	</div>
</section>
<{/block}>

<{block name=js}>
<script type="text/javascript">
	function loadPri () 
	{
		var uid = window.location.search.slice(1).split('=')[1];
		ajaxObj('/UserManage/getUserPer', 'get', {uid}, function(obj){
			obj.userPer.map(function(data){
				if(data.value == 'off'){
					$('[name=' + data.key + ']').attr('checked', 'checked');
				}
			})
		})
	}

	loadPri();

	$('.savePri').click(function(){
		var uid = window.location.search.slice(1).split('=')[1];
		var dataObj = {};
		$('.m-userDetail-box input').each(function(index, data){
			var key = $(data).attr('name');
			var value = $(data).attr('checked') ? 'on' : 'off';
			dataObj[key] = value;
		})
		ajaxObj('/UserManage/updateUserPer', 'post', {data: dataObj, uid}, function(obj){
			if(obj.code == 1){
				layer.msg('保存成功！');
			}
		})
	})


</script>
<{/block}>